home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Menu / c / Show < prev    next >
Text File  |  1995-07-10  |  2KB  |  75 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Menu.AddSubMenu.c
  12.     Author:  Copyright © 1993 Shaun Blackmore and Jason Williams
  13.     Version: 1.00 (30 Apr 1993)
  14.     Purpose: Adds one menu to another as a submenu
  15. */
  16.  
  17. #include "DeskLib:Wimp.h"
  18. #include "DeskLib:WimpSWIs.h"
  19. #include "DeskLib:Menu.h"
  20.  
  21.  
  22. wimp_point menu_currentpos;
  23. menu_ptr   menu_currentopen = NULL;
  24.  
  25.  
  26. #ifdef _DLL
  27. wimp_point    *Menu__Ref_currentpos( void)    { return &menu_currentpos;    }
  28. menu_ptr    *Menu__Ref_currentopen( void)    { return &menu_currentopen;    }
  29. #endif
  30.  
  31.  
  32. int Menu_CalcHeight(menu_ptr menu)
  33. {
  34.   int       itemheight, count = 0;
  35.   menu_item *item;
  36.  
  37.   item = (menu_item *) (((int) menu) + sizeof(menu_block));
  38.   itemheight = menu->height + menu->gap;
  39.  
  40.   while(TRUE)
  41.   {
  42.     if (item->menuflags.data.dotted)         /* Count height of dotted line  */
  43.       count += 24;
  44.  
  45.     count += itemheight;                     /* Plus the height of each item */
  46.  
  47.     if (item->menuflags.data.last)
  48.       break;
  49.  
  50.     item++;
  51.   }
  52.  
  53.   return(count);
  54. }
  55.  
  56.  
  57. void Menu_Show(menu_ptr menu, int x, int y)
  58. {                    
  59.   x -= 64;
  60.   if (y < 0)
  61.     y = 96 + Menu_CalcHeight(menu);            /* Calculate iconbar position */
  62.  
  63.   menu_currentopen  = menu;
  64.   menu_currentpos.x = x;
  65.   menu_currentpos.y = y;
  66.  
  67.   Wimp_CreateMenu(menu, x, y);
  68. }
  69.  
  70.  
  71. void Menu_ShowLast(void)
  72. {
  73.   Wimp_CreateMenu(menu_currentopen, menu_currentpos.x, menu_currentpos.y);
  74. }
  75.